package cn.lili.modules.order.order.entity.dto;

import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.order.order.entity.dos.PrizeGoods;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@Data
public class PrizeGoodsDTO extends PageVO {

    /**
     * 奖品id
     */
    @NotEmpty(message = "奖品id不可为空")
    private String id;

    /**
     * 奖品名字
     */
    private String goodsName;

    /**
     * 1实物商品，2虚拟商品
     */
    private Integer goodsType;

    /**
     * 是否需要领取，1需要，2不需要
     */
    private Integer isNeedToCollect;

    /**
     * 发布状态： 0待发布，1发布，2下架
     */
    @NotNull(message = "发布状态不可为空")
    private Integer publishType;


    public LambdaQueryWrapper<PrizeGoods> toQueryWrapper() {
        LambdaQueryWrapper<PrizeGoods> query = new LambdaQueryWrapper<>();
        query.eq(StringUtils.isNotEmpty(id), PrizeGoods::getId, id);
        query.like(StringUtils.isNotEmpty(goodsName), PrizeGoods::getGoodsName, goodsName);
        query.eq(null != goodsType, PrizeGoods::getGoodsType, goodsType);
        query.eq(null != isNeedToCollect, PrizeGoods::getIsNeedToCollect, isNeedToCollect);
        query.eq(null != publishType, PrizeGoods::getIsNeedToCollect, publishType);

        query.orderByDesc(PrizeGoods::getCreateTime).orderByDesc(PrizeGoods::getId);
        return query;
    }
}
